package vn.com.baseapplication.service;

import vn.com.baseapplication.network.BaseNetwork;
import vn.com.baseapplication.network.NetworkHandlerCallback;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.IBinder;

public class BaseService extends Service implements NetworkHandlerCallback,BaseReceiverListener{
	protected BaseNetwork network;
	private BaseBinder mBinder = new BaseBinder(this);
	private BaseReceiver baseReceiver = new BaseReceiver(this);
	
	@Override
	public IBinder onBind(Intent intent) {
		initService();
		return mBinder;
	}
	
	@Override
	public void onCreate() {
		super.onCreate();
		initService();
	}
	
	private void initService(){
		network = new BaseNetwork(this);
	}
	
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {
		return Service.START_NOT_STICKY;
	}
	
	@Override
	public void onNetLoading(int requestId) {
		
	}
	@Override
	public void onNetSuccess(int requestId, String response) {
		
	}
	@Override
	public void onNetSuccessCache(int requestId, String response) {
		
	}
	@Override
	public void onNetTimeOut(int requestId, Throwable error) {
		
	}
	@Override
	public void onNetFailed(int requestId, String error) {
		
	}

	@Override
	public void sendBaseBroadcast(Context context, Intent intent) {
		baseReceiver.sendBaseBroadcast(context, intent);
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		
	}
}
